/**
 * (c) 2007 Joern Dinkla, www.dinkla.net
 * 
 *
 * $Id$
 */
package CWM.Olap.provider;

import CWM.Olap.util.OlapAdapterFactory;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class OlapItemProviderAdapterFactory extends OlapAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OlapItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.ContentMap} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ContentMapItemProvider contentMapItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.ContentMap}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createContentMapAdapter() {
		if (contentMapItemProvider == null) {
			contentMapItemProvider = new ContentMapItemProvider(this);
		}

		return contentMapItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.Cube} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CubeItemProvider cubeItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.Cube}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCubeAdapter() {
		if (cubeItemProvider == null) {
			cubeItemProvider = new CubeItemProvider(this);
		}

		return cubeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.CubeDeployment} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CubeDeploymentItemProvider cubeDeploymentItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.CubeDeployment}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCubeDeploymentAdapter() {
		if (cubeDeploymentItemProvider == null) {
			cubeDeploymentItemProvider = new CubeDeploymentItemProvider(this);
		}

		return cubeDeploymentItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.CubeDimensionAssociation} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CubeDimensionAssociationItemProvider cubeDimensionAssociationItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.CubeDimensionAssociation}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCubeDimensionAssociationAdapter() {
		if (cubeDimensionAssociationItemProvider == null) {
			cubeDimensionAssociationItemProvider = new CubeDimensionAssociationItemProvider(this);
		}

		return cubeDimensionAssociationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.CubeRegion} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CubeRegionItemProvider cubeRegionItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.CubeRegion}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCubeRegionAdapter() {
		if (cubeRegionItemProvider == null) {
			cubeRegionItemProvider = new CubeRegionItemProvider(this);
		}

		return cubeRegionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.DeploymentGroup} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DeploymentGroupItemProvider deploymentGroupItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.DeploymentGroup}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createDeploymentGroupAdapter() {
		if (deploymentGroupItemProvider == null) {
			deploymentGroupItemProvider = new DeploymentGroupItemProvider(this);
		}

		return deploymentGroupItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.Dimension} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DimensionItemProvider dimensionItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.Dimension}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createDimensionAdapter() {
		if (dimensionItemProvider == null) {
			dimensionItemProvider = new DimensionItemProvider(this);
		}

		return dimensionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.DimensionDeployment} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DimensionDeploymentItemProvider dimensionDeploymentItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.DimensionDeployment}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createDimensionDeploymentAdapter() {
		if (dimensionDeploymentItemProvider == null) {
			dimensionDeploymentItemProvider = new DimensionDeploymentItemProvider(this);
		}

		return dimensionDeploymentItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.HierarchyLevelAssociation} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected HierarchyLevelAssociationItemProvider hierarchyLevelAssociationItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.HierarchyLevelAssociation}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createHierarchyLevelAssociationAdapter() {
		if (hierarchyLevelAssociationItemProvider == null) {
			hierarchyLevelAssociationItemProvider = new HierarchyLevelAssociationItemProvider(this);
		}

		return hierarchyLevelAssociationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.LevelBasedHierarchy} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected LevelBasedHierarchyItemProvider levelBasedHierarchyItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.LevelBasedHierarchy}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createLevelBasedHierarchyAdapter() {
		if (levelBasedHierarchyItemProvider == null) {
			levelBasedHierarchyItemProvider = new LevelBasedHierarchyItemProvider(this);
		}

		return levelBasedHierarchyItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.MemberSelectionGroup} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MemberSelectionGroupItemProvider memberSelectionGroupItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.MemberSelectionGroup}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createMemberSelectionGroupAdapter() {
		if (memberSelectionGroupItemProvider == null) {
			memberSelectionGroupItemProvider = new MemberSelectionGroupItemProvider(this);
		}

		return memberSelectionGroupItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.MemberSelection} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MemberSelectionItemProvider memberSelectionItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.MemberSelection}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createMemberSelectionAdapter() {
		if (memberSelectionItemProvider == null) {
			memberSelectionItemProvider = new MemberSelectionItemProvider(this);
		}

		return memberSelectionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.Schema} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SchemaItemProvider schemaItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.Schema}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSchemaAdapter() {
		if (schemaItemProvider == null) {
			schemaItemProvider = new SchemaItemProvider(this);
		}

		return schemaItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.ValueBasedHierarchy} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ValueBasedHierarchyItemProvider valueBasedHierarchyItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.ValueBasedHierarchy}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createValueBasedHierarchyAdapter() {
		if (valueBasedHierarchyItemProvider == null) {
			valueBasedHierarchyItemProvider = new ValueBasedHierarchyItemProvider(this);
		}

		return valueBasedHierarchyItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.Level} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected LevelItemProvider levelItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.Level}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createLevelAdapter() {
		if (levelItemProvider == null) {
			levelItemProvider = new LevelItemProvider(this);
		}

		return levelItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.CodedLevel} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CodedLevelItemProvider codedLevelItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.CodedLevel}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCodedLevelAdapter() {
		if (codedLevelItemProvider == null) {
			codedLevelItemProvider = new CodedLevelItemProvider(this);
		}

		return codedLevelItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.Measure} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MeasureItemProvider measureItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.Measure}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createMeasureAdapter() {
		if (measureItemProvider == null) {
			measureItemProvider = new MeasureItemProvider(this);
		}

		return measureItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.StructureMap} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected StructureMapItemProvider structureMapItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.StructureMap}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createStructureMapAdapter() {
		if (structureMapItemProvider == null) {
			structureMapItemProvider = new StructureMapItemProvider(this);
		}

		return structureMapItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.HierarchyMemberSelectionGroup} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected HierarchyMemberSelectionGroupItemProvider hierarchyMemberSelectionGroupItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.HierarchyMemberSelectionGroup}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createHierarchyMemberSelectionGroupAdapter() {
		if (hierarchyMemberSelectionGroupItemProvider == null) {
			hierarchyMemberSelectionGroupItemProvider = new HierarchyMemberSelectionGroupItemProvider(this);
		}

		return hierarchyMemberSelectionGroupItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Olap.Olap_container} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Olap_containerItemProvider olap_containerItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Olap.Olap_container}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createOlap_containerAdapter() {
		if (olap_containerItemProvider == null) {
			olap_containerItemProvider = new Olap_containerItemProvider(this);
		}

		return olap_containerItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (contentMapItemProvider != null) contentMapItemProvider.dispose();
		if (cubeItemProvider != null) cubeItemProvider.dispose();
		if (cubeDeploymentItemProvider != null) cubeDeploymentItemProvider.dispose();
		if (cubeDimensionAssociationItemProvider != null) cubeDimensionAssociationItemProvider.dispose();
		if (cubeRegionItemProvider != null) cubeRegionItemProvider.dispose();
		if (deploymentGroupItemProvider != null) deploymentGroupItemProvider.dispose();
		if (dimensionItemProvider != null) dimensionItemProvider.dispose();
		if (dimensionDeploymentItemProvider != null) dimensionDeploymentItemProvider.dispose();
		if (hierarchyLevelAssociationItemProvider != null) hierarchyLevelAssociationItemProvider.dispose();
		if (levelBasedHierarchyItemProvider != null) levelBasedHierarchyItemProvider.dispose();
		if (memberSelectionGroupItemProvider != null) memberSelectionGroupItemProvider.dispose();
		if (memberSelectionItemProvider != null) memberSelectionItemProvider.dispose();
		if (schemaItemProvider != null) schemaItemProvider.dispose();
		if (valueBasedHierarchyItemProvider != null) valueBasedHierarchyItemProvider.dispose();
		if (levelItemProvider != null) levelItemProvider.dispose();
		if (codedLevelItemProvider != null) codedLevelItemProvider.dispose();
		if (measureItemProvider != null) measureItemProvider.dispose();
		if (structureMapItemProvider != null) structureMapItemProvider.dispose();
		if (hierarchyMemberSelectionGroupItemProvider != null) hierarchyMemberSelectionGroupItemProvider.dispose();
		if (olap_containerItemProvider != null) olap_containerItemProvider.dispose();
	}

}
